home *** CD-ROM | disk | FTP | other *** search
/ Programmer Power Tools / Programmer Power Tools.iso / progjrn / pj_7_2.arc / EXAMPLE.ASM < prev    next >
Assembly Source File  |  1989-02-26  |  2KB  |  69 lines

  1. ; EXAMPLE.asm
  2. ; sample code fragment showing runtime dynamic linking
  3. ;
  4. ; By Ray Duncan
  5.  
  6.  
  7. objbuf  db      64 dup (0)      ; receives failing module
  8.                                 ; or entry point name
  9.  
  10. objbuf_len equ  $-objbuf
  11.  
  12. mname   db      'VIOCALLS',0    ; module name
  13.  
  14. mhandle dw      0               ; receives module handle
  15.  
  16. ename   db      'VIOGETANSI',0  ; entry point name
  17.  
  18. eptr    dd      0               ; receives far pointer
  19.                                 ; to entry point
  20.  
  21.         .
  22.         .
  23.         .
  24.                                 ; attach to DLL...
  25.         push    ds              ; receives failing dynlink
  26.         push    offset DGROUP:objbuf
  27.         push    objbuf_len      ; length of buffer
  28.         push    ds              ; address of module name
  29.         push    offset DGROUP:mname
  30.         push    ds              ; receives module handle
  31.         push    offset DGROUP:mhandle
  32.         call    DosLoadModule   ; transfer to OS/2
  33.         or      ax,ax           ; module found?
  34.         jnz     error           ; jump if no such module
  35.  
  36.                                 ; get entry point...
  37.         push    mhandle         ; module handle
  38.         push    ds              ; address of entry name
  39.         push    offset DGROUP:ename
  40.         push    ds              ; receives entry pointer
  41.         push    offset DGROUP:eptr
  42.         call    DosGetProcAddr  ; transfer to OS/2
  43.         or      ax,ax           ; entry point found?
  44.         jnz     error           ; jump if no entry point
  45.  
  46.         .
  47.         .                       ; other processing here...
  48.         .
  49.  
  50.         call    eptr            ; indirect call to
  51.                                 ; dynlink library routine
  52.  
  53.         .
  54.         .                       ; other processing here...
  55.         .
  56.  
  57.                                 ; module no longer
  58.                                 ; needed, release it...
  59.         push    mhandle         ; module handle
  60.         call    DosFreeModule   ; transfer to OS/2î        or      ax,ax           ; should never fail
  61.         jnz     error           ; but check anyway
  62.         .
  63.         .
  64.         .
  65.  
  66.  
  67.  
  68.